package com.ruoyi.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author :songzl
 * @date :2018/6/8 16:27
 * @description:
 */
@Configuration
@EnableSwagger2
//@EnableWebMvc
//@ComponentScan(basePackages = {"com.ruoyi.project.system.user.controller"})
public class SwaggerConfig {
    //swagger2的配置文件，这里可以配置swagger2的一些基本的内容，比如扫描的包等等
    @Bean
    public Docket platformApi(){
//        return new Docket(DocumentationType.SWAGGER_2).groupName("api").apiInfo(apiInfo()).forCodeGeneration(true);
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.system.user.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    //构建 api文档的详细信息函数,注意这里的注解引用的是哪个
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Spring Boot 测试使用 Swagger2 构建RESTful API")
                .description("Copyright © 2018, zhonglin.song, All Rights Reserved.")
                .contact(new Contact("songzhonglin", "", "songzhonglin0616@163.com"))
                .license("Apache License Version 1.0")
//                .termsOfServiceUrl("")
                .version("1.0")
                .build();
    }
}
